<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/comm :: head "></head>
<body>
<div class="wrapper">
    <header th:replace="common/comm :: header "></header>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">
                    <font id="WOW_TRANSLATE_43" class="WOW_TRANSLATE_STYLE"
                          data--w-o-w_-i-n-d-e-x="43">数据分析</font>
                </h4>
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="card-title">职员数据综合报表
                                    <span th:if="${year != null}" th:text="|---${year}年|"></span></div>
                            </div>
                            <div class="card-body">
                                <div class="card-sub">
                                    <div class="card-body" th:if="${list != null && list.size() != 0}">
                                        <table class="table table-striped mt-3">
                                            <tr>
                                                <td>部门\学历</td>
                                                <td>总人数</td>
                                                <td th:each="info:${educations}" th:text="${info.valueName}"></td>
                                            </tr>
                                            <tr th:each="info:${list}">
                                                <td th:text="${info.oName}"></td>
                                                <td th:text="${info.sum}"></td>
                                                <td th:each="educat:${info.education}"
                                                    th:text="${educat.counto}"></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div th:if="${list == null || list.size() == 0}">
                                        暂时没有记录.....
                                    </div>
                                </div>
                            </div>
                            <div id="chart" style="margin: 0 auto;width:800px;height:600px;"></div>
                            <div class="form-group" style="text-align: center;">
                                <button class="btn btn-danger" onclick="javascript:window.history.back();">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <footer th:replace="common/comm :: footer "></footer>
</div>
<script src="/js/echarts.min.js"></script>
<script th:inline="javascript">
    var title = [[${year}]] + "年度员工学历发布";
    var educations = [[${educations}]];
    var list = [[${list}]];
    var data = [];
    for (var i = 0; i < educations.length; i++) {
        data[i] = {value: 0, name: educations[i].valueName};
    }
    for (var j = 0; j < list.length; j++) {
        var education = list[j].education;
        for (var k = 0; k < education.length; k++) {
            data[k].value += education[k].counto;
        }
    }
    // 初始化图表标签
    var myChart = echarts.init(document.getElementById('chart'));
    var option = {
        backgroundColor: '#2c343c',
        textStyle: {
            color: '#ccc',
            fontSize: 20
        },

        title: {
            text: title,
            left: 'center',
            top: 20,
            textStyle: {
                color: '#ccc',
                fontSize: 24
            }
        },

        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },

        visualMap: {
            show: false,
            min: 0,
            max: 0,
            inRange: {
                colorLightness: [0, 1]
            }
        },
        series: [
            {
                name: '人数',
                type: 'pie',
                radius: '55%',
                center: ['50%', '50%'],
                data: data.sort(function (a, b) {
                    return a.value - b.value;
                }),
                roseType: 'radius',
                label: {
                    normal: {
                        textStyle: {
                            color: 'rgba(255, 255, 255, 0.3)'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        lineStyle: {
                            color: 'rgba(255, 255, 255, 0.3)'
                        },
                        smooth: 0.2,
                        length: 10,
                        length2: 20
                    }
                },
                itemStyle: {
                    normal: {
                        color: '#c23531',
                        shadowBlur: 200,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                },

                animationType: 'scale',
                animationEasing: 'elasticOut',
                animationDelay: function (idx) {
                    return Math.random() * 200;
                }
            }
        ]
    };
    myChart.setOption(option);
</script>
</body>
</html>